<?php
namespace app\index\controller;

use think\Request;
use \app\admin\model\Technology as TechnologyModel;

class Technology extends Base
{
    protected $model;

    public function __construct(Request $request = null)
    {
        parent::__construct($request);

        $this->model = new TechnologyModel();
    }

    public function index($id = null)
    {
        $data = $this->model->find($id);
        
        $data->clicks +=1;
        
        @$data->save();

        $banner = $this->category_model->where('id', 42)->value('banner');
        
        $this->assign('data', $data);
        $this->assign('banner', $banner);
        return $this->fetch();
    }
    
    public function lists()
    {
        $cid = 42;
       // banner,img_title图
        $data_banner =  $this->category_model->where('id', $cid)->field('banner, img_title')->find();

        $data = $this->model->field('id, title, thumb, summary')
            ->where('status', 1)
            ->order('id desc, top')
            ->paginate(4);

        $this->assign('data', $data);
        $this->assign('data_banner', $data_banner);
        return $this->fetch();
    }
}
